package com.tvshows.domain.util.enums;

public enum Schedule {

    MONDAY(2, "Monday"),

    TUESDAY(3, "Tuesday"),

    WEDNESDAY(4, "Wednesday"),

    THURSDAY(5, "Thursday"),

    FRIDAY(6, "Friday"),

    SATURDAY(7, "Saturday"),

    SUNDAY(1, "Sunday");

    private final Integer numDay;

    private static final Integer DAYS_NUMBER = 7;

    private final String dayName;

    /**
     * @param numDay  The day number
     * @param dayName the day name
     */
    private Schedule(int numDay, String dayName) {
        this.numDay = numDay;
        this.dayName = dayName;
    }

    /**
     * @param numDay the day number
     */
    public static Schedule fromNumDay(int numDay) {

        for (Schedule s : values()) {
            if (s.getNumDay() == numDay) {
                return s;
            }
        }
        return null;
    }

    /**
     * @param dayName the day name
     */
    public static Schedule fromDayName(String dayName) {
        return Schedule.valueOf(dayName.toUpperCase());
    }

    /**
     * Render the values to string
     */
    public static String[] toStringValues() {
        String[] values = new String[DAYS_NUMBER];
        int val = 0;
        for (Schedule s : values()) {
            values[val] = s.getDayName();
            val++;
        }
        return values;
    }

    /**
     * @return the numDay
     */
    public int getNumDay() {
        return numDay;
    }

    /**
     * @return the dayName
     */
    public String getDayName() {
        return dayName;
    }
}
